#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V;
int ans1=0,ans2=0;
struct node
{
    double car_d,car_v,car_a;
}car[100005];
bool cmp(pair<int,int> x,pair<int,int> y)
{
    return (x.first==y.first?x.second>y.second:x.first<y.first);
}
double cesu[100005];
int viscesu[100005],cnt=0;
vector<pair<int,int> > cesunum;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        ans1=ans2=0;
        memset(viscesu,0,sizeof(viscesu));
        cnt=0;
        cesunum.clear();
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].car_d>>car[i].car_v>>car[i].car_a;
        }
        for(int i=1;i<=m;i++)cin>>cesu[i];
        double chaosu;
        int chaostart,chaoend;
        for(int i=1;i<=n;i++)
        {
            if(car[i].car_a!=0)
            {
                chaosu=(V*V-car[i].car_v*car[i].car_v)/car[i].car_a/2.0+car[i].car_d;
                if(car[i].car_a<0&&car[i].car_v>V)
                {
                    if(chaosu>cesu[lower_bound(cesu+1,cesu+1+m,car[i].car_d)-cesu])
                    {
                        ans1++;
                        chaostart=lower_bound(cesu+1,cesu+1+m,car[i].car_d)-cesu;
                        chaoend=lower_bound(cesu+1,cesu+1+m,chaosu)-cesu-1;
                        cesunum.push_back(make_pair(chaostart,chaoend));
                    }
                }
                else if(car[i].car_a>0&&car[i].car_v<V)
                {
                    if(chaosu<cesu[m])
                    {
                        ans1++;
                        chaostart=upper_bound(cesu+1,cesu+m+1,chaosu)-cesu;
                        cesunum.push_back(make_pair(chaostart,m));
                    }
                }
                else if(car[i].car_a>0&&car[i].car_v>V)
                {
                    if(car[i].car_d<=cesu[m])
                    {
                        ans1++;
                        chaostart=lower_bound(cesu+1,cesu+1+m,car[i].car_d)-cesu;
                        cesunum.push_back(make_pair(chaostart,m));
                    }
                }
                else if(car[i].car_a>0&&car[i].car_v==V)
                {
                    if(car[i].car_d<cesu[m])
                    {
                        ans1++;
                        chaostart=upper_bound(cesu+1,cesu+1+m,car[i].car_d)-cesu;
                        cesunum.push_back(make_pair(chaostart,m));
                    }
                }
            }
            else
            {
                if(car[i].car_v>V)
                {
                    ans1++;
                    chaostart=lower_bound(cesu+1,cesu+1+m,car[i].car_d)-cesu;
                    cesunum.push_back(make_pair(chaostart,m));
                }
            }

        }
        cout<<ans1<<' ';
        sort(cesunum.begin(),cesunum.end(),cmp);
        bool f=0;
        //for(int i=0;i<cesunum.size();i++)cout<<'('<<cesunum[i].first<<','<<cesunum[i].second<<')'<<' ';cout<<'\n';
        do
        {
            f=0;
            for(int i=1;i<cesunum.size();i++)
            {
                if(cesunum[i].second<=cesunum[i-1].second)cesunum.erase(cesunum.begin()+i-1),i--,f=1;
            }
        }while(f==1);
        for(int i=1;i<cesunum.size();i++)
        {
            if(cesunum[i-1].second>=cesunum[i].first)
            {
                ans2++;
                viscesu[i-1]=viscesu[i]=1;
            }
        }
        //for(int i=0;i<cesunum.size();i++)cout<<'('<<cesunum[i].first<<','<<cesunum[i].second<<','<<viscesu[i]<<')'<<' ';cout<<'\n';
        for(int i=0;i<cesunum.size();i++)if(viscesu[i]!=1)cnt++;
        cout<<m-(ans2+cnt)<<'\n';
    }
    return 0;
}
